package main

import (
	_ "beegoProject04/models/user"
	_ "beegoProject04/routers"
	"beegoProject04/utils"
	"fmt"
	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
	_ "github.com/go-sql-driver/mysql"
)

/*
9.21【用户模块】用户列表数据显示优化
	1. user-list.html 增加性别判断72H，启停显示判断84H，启停按钮判断94H

9.22【用户模块】用户列表分页一
	1. 分页显示逻辑：user_controller.go
	2. 修改页面动态按钮 user-list.html 90H，

9.23【用户模块】用户列表分页二
	1. 修改页面动态按钮 user-list.html 125H，46H(数据量),


*/

func init() {
	user := beego.AppConfig.DefaultString("mysql::Username", "root")
	pwd := beego.AppConfig.DefaultString("mysql::Password", "Ideal123")
	host := beego.AppConfig.DefaultString("mysql::Host", "127.0.0.1")
	port := beego.AppConfig.DefaultInt("mysql::Port", 3306)
	db := beego.AppConfig.DefaultString("mysql::DbName", "beegoProject")

	dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=true&loc=PRC",
		user, pwd, host, port, db)

	orm.RegisterDriver("mysql", orm.DRMySQL)
	orm.RegisterDataBase("default", "mysql", dsn)

}

func main() {
	orm.RunCommand()
	orm.Debug = true
	beego.BConfig.WebConfig.Session.SessionOn = true

	// 未登录请求拦截
	beego.InsertFilter("/main/*", beego.BeforeRouter, utils.LoginFilter)

	beego.Run()
}
